//
//  MKTChatItem_8_TVCell.m
//  MKUITestApp
//
//  Created by 苏尚进 on 2021/7/14.
//  Copyright © 2021 moon. All rights reserved.
//

#import "MKTChatItem_8_TVCell.h"

@implementation MKTChatItem_8_TVCell
+ (void)load{
    [self registerTableViewCellFor:[MKTChatItem_8 class]];
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.ititleLabel = [[UILabel alloc] init];
        self.ititleLabel.font = [UIFont systemFontOfSize:12];
        self.ititleLabel.textAlignment = NSTextAlignmentCenter;
        self.ititleLabel.numberOfLines = 1;
        self.ititleLabel.textColor = [UIColor mk_colorWithLight:[UIColor grayColor] dark:[UIColor lightTextColor]];
        [self.contentView addSubview:self.ititleLabel];
        //
        self.valueView = [[MKTChatLabelValueUIView alloc] init];
        self.valueView.textFont = [UIFont systemFontOfSize:24];
        self.valueView.moneyUnitFont = [UIFont systemFontOfSize:14];
        self.valueView.label.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.valueView];
        //
        self.subvalueView = [[MKTChatLabelValueUIView alloc] init];
        self.subvalueView.textFont = [UIFont systemFontOfSize:12];
        self.subvalueView.normalColor = [UIColor mk_colorWithLight:[UIColor grayColor] dark:[UIColor lightTextColor]];
        [self.contentView addSubview:self.subvalueView];
        //
        MKUIFlowLayoutConstraint *f1 = [[MKUIFlowLayoutConstraint alloc] initWithItems:@[self.valueView,self.subvalueView] constraintParam:(MKUIFlowLayoutConstraintParam_H_B_C) contentInsets:UIEdgeInsetsMake(0, 0, 0, 0) interitemSpacing:5];
        self.flowlayout = [[MKUIFlowLayoutConstraint alloc] initWithItems:@[self.ititleLabel,f1] constraintParam:(MKUIFlowLayoutConstraintParam_V_C_C) contentInsets:MKUIEdgeInsetsMakeSameEdge(10) interitemSpacing:10];
    }
    return self;
}
- (void)customLayoutSubviews{
    [super customLayoutSubviews];
    CGRect bounds = self.contentView.bounds;
    self.flowlayout.bounds = bounds;
    [self.flowlayout layoutItemsWithResizeItems:YES];
}
- (CGSize)customSizeThatFits:(CGSize)size{
    return [self.flowlayout sizeThatFits:size resizeItems:YES];
}
- (void)customReloadCellModel{
    [super customReloadCellModel];
    MKTChatItem_8 *modeValue = self.cellModel.modelValue;
    self.ititleLabel.text = modeValue.itext;
    self.valueView.labelValue = modeValue.value;
    [self.valueView reloadData];
    self.subvalueView.labelValue = modeValue.subvalue;
    [self.subvalueView reloadData];
}
@end
